<?php
    echo Modules::run('ndh/header');
?>
<div class="clear" style="padding-bottom: 5px;"></div>   
        <div id="mainContent" style="width: 987px;">
            <table width="987" align="center" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
                <tr valign="top">
                    <td>
                        <div id="leftContent" style="background-color: #FFFFFF;">
                        <?php
                            if(isset($detail_news['title']))
                            {
                        ?>
                <div style="padding: 10px 10pt 10pt; background-color: #FFFFFF;">
                    <h1><?php echo $detail_news['title']; ?></h1>
                </div>
                <div class="mainDetail">
                    <?php echo $detail_news['detail'];
                            }
                    ?>
                </div>
                <!-- other news -->
                <div style="padding:10px;border-top: 3px solid #EEEEEE; background-color: #FFFFFF;">
                    <h1>TIN TỨC - SỰ KIỆN</h1>
                    <br/>
                    <div id="otherNews">
                        <ul>
                            <?php   
                                if(isset($other_news))                         
                                {
                                    foreach($other_news as $news)
                                    {
                            ?>
                            <li><a href="<?php echo site_url('ndh/news/index/'.$news['id'].'/') ?>"><?php echo $news['title']; ?></a></li>
                            <?php
                                    }
                                }
                            ?>
                        </ul>
                    </div>
                </div>
                <!-- other news -->
                <!-- thong tin công ty -->
                <div style="padding:10px;border-top: 3px solid #EEEEEE; background-color: #FFFFFF;">
                    <h1>HỒ SƠ CÔNG TY</h1>
                </div>
                <div id="tabs">
                    <ul>
                        <li><a href="#tabs-1">Tài chính</a></li>
                        <li><a href="#tabs-2">Cơ bản</a></li>
                        <li><a href="#tabs-3">Ban lãnh đạo</a></li>
                        <li><a href="#tabs-4">Phân tích cơ bản</a></li>
                        <li><a href="#tabs-5">Phân tích kỹ thuật</a></li>
                    </ul>
                    <div id="tabs-1">
                        <div align="left" style="font-size: 12px; width: 100%;">
                        <?php 
                            if(!empty($company_info['finance_basic']))
                            {
                        ?>
                            <table border="0" width="100%">
                                <tr bgcolor="#2F96B4" style="color: #FFFFFF; height: 24;">
                                    <td width="165">Phân tích HĐKD</td>
                                    <?php 
                                        foreach($company_info['finance_basic'] as $finance)
                                        {
                                    ?>
                                    <td align="center"><? echo $finance['year'];?></td>
                                    <?php 
                                        }                                        
                                    ?>
                                </tr>
                                <tr>
                                    <td width="165"></td>
                                    <?php 
                                        foreach($company_info['finance_basic'] as $finance)
                                        {
                                    ?>
                                    <td align="center">
                                        <table width="100%" border="0">
                                            <tr>
                                                <td align="center">Tổng</td>
                                                <td align="center">Tăng trưởng</td>
                                            </tr>
                                        </table>
                                    </td>
                                     <?php 
                                        }                                        
                                    ?>
                                </tr>
                                <tr bgcolor="#F6F6F6">
                                    <td>Doanh thu</td>
                                    <?php 
                                        foreach($company_info['finance_basic'] as $finance)
                                        {
                                    ?>
                                    <td>
                                        <table border="0" width="100%">
                                            <tr><td align="left"><? echo $finance['top_balance'];?></td><td align="center"><? echo $finance['balance_increase']."%";?></td></tr>
                                        </table>
                                    </td>
                                    <?php                                             
                                        }
                                    ?>
                                </tr>
                                <tr>
                                    <td>Lợi nhuận HĐKD</td>
                                    <?php 
                                        foreach($company_info['finance_basic'] as $finance)
                                        {
                                    ?>
                                    <td>
                                        <table border="0" width="100%">
                                            <tr><td align="left" colspan="2"><? echo $finance['top_contract_profit'];?></td></tr>
                                        </table>
                                    </td>
                                    <?php                                             
                                        }
                                    ?>
                                </tr>
                                <tr bgcolor="#F6F6F6">
                                    <td>LNST</td>
                                    <?php 
                                        foreach($company_info['finance_basic'] as $finance)
                                        {
                                    ?>
                                    <td>
                                        <table border="0" width="100%">
                                            <tr><td align="left" colspan="2"><? echo $finance['top_net_profit'];?></td></tr>
                                        </table>
                                    </td>
                                    <?php                                             
                                        }
                                    ?>
                                </tr>
                                <tr>
                                    <td>Tỷ suất lợi nhuận ròng</td>
                                    <?php 
                                        foreach($company_info['finance_basic'] as $finance)
                                        {
                                    ?>
                                    <td>
                                        <table border="0" width="100%">
                                            <tr><td align="left" colspan="2"><? echo $finance['net_profit_percent'].'%';?></td></tr>
                                        </table>
                                    </td>
                                    <?php                                             
                                        }
                                    ?>
                                </tr>
                                <tr>
                                    <td></td>
                                    <?php 
                                        foreach($company_info['finance_basic'] as $finance)
                                        {
                                            
                                    ?>
                                    <td align="center">
                                    <?php 
                                            if(!empty($finance['chart']))
                                            {
                                    ?>
                                        <img width="80" height="70" src="<?php echo base_url('uploads/company/report/'.$finance['chart']);?>" alt="">
                                    <?php   } ?>
                                    </td>
                                    <?php                                                                                         
                                        }
                                    ?>
                                </tr>
                                <tr bgcolor="#F6F6F6">
                                    <td>ROE(%)</td>
                                    <?php 
                                        foreach($company_info['finance_basic'] as $finance)
                                        {
                                    ?>
                                    <td>
                                        <table border="0" width="100%">
                                            <tr><td align="left" colspan="2"><? echo $finance['roe'].'%';?></td></tr>
                                        </table>
                                    </td>
                                    <?php                                             
                                        }
                                    ?>
                                </tr>
                                <tr>
                                    <td>Tiền mặt tại quỹ</td>
                                    <?php 
                                        foreach($company_info['finance_basic'] as $finance)
                                        {
                                    ?>
                                    <td>
                                        <table border="0" width="100%">
                                            <tr><td align="left" colspan="2"><? echo $finance['current_money'];?></td></tr>
                                        </table>
                                    </td>
                                    <?php                                             
                                        }
                                    ?>
                                </tr>
                                 <tr bgcolor="#F6F6F6">
                                    <td>TTS</td>
                                    <?php 
                                        foreach($company_info['finance_basic'] as $finance)
                                        {
                                    ?>
                                    <td>
                                        <table border="0" width="100%">
                                            <tr><td align="left" colspan="2"><? echo $finance['top_asset'];?></td></tr>
                                        </table>
                                    </td>
                                    <?php                                             
                                        }
                                    ?>
                                </tr>
                                <tr>
                                    <td>VCSH</td>
                                    <?php 
                                        foreach($company_info['finance_basic'] as $finance)
                                        {
                                    ?>
                                    <td>
                                        <table border="0" width="100%">
                                            <tr><td align="left" colspan="2"><? echo $finance['vcsh'];?></td></tr>
                                        </table>
                                    </td>
                                    <?php                                             
                                        }
                                    ?>
                                </tr>
                                <tr bgcolor="#F6F6F6">
                                    <td>Nợ</td>
                                    <?php 
                                        foreach($company_info['finance_basic'] as $finance)
                                        {
                                    ?>
                                    <td>
                                        <table border="0" width="100%">
                                            <tr><td align="left" colspan="2"><? echo $finance['total_debt'];?></td></tr>
                                        </table>
                                    </td>
                                    <?php                                             
                                        }
                                    ?>
                                </tr>
                                <tr>
                                    <td>NNH</td>
                                    <?php 
                                        foreach($company_info['finance_basic'] as $finance)
                                        {
                                    ?>
                                    <td>
                                        <table border="0" width="100%">
                                            <tr><td align="left" colspan="2"><? echo $finance['short_debt'];?></td></tr>
                                        </table>
                                    </td>
                                    <?php                                             
                                        }
                                    ?>
                                </tr>
                                <tr bgcolor="#F6F6F6">
                                    <td>Hệ số nợ/ tổng tài sản</td>
                                    <?php 
                                        foreach($company_info['finance_basic'] as $finance)
                                        {
                                    ?>
                                    <td>
                                        <table border="0" width="100%">
                                            <tr><td align="left" colspan="2"><? echo $finance['hsn'].'%';?></td></tr>
                                        </table>
                                    </td>
                                    <?php                                             
                                        }
                                    ?>
                                </tr>
                                <tr>
                                    <td>Vay NH</td>
                                    <?php 
                                        foreach($company_info['finance_basic'] as $finance)
                                        {
                                    ?>
                                    <td>
                                        <table border="0" width="100%">
                                            <tr><td align="left" colspan="2"><? echo $finance['vnh'];?></td></tr>
                                        </table>
                                    </td>
                                    <?php                                             
                                        }
                                    ?>
                                </tr>
                                <tr bgcolor="#F6F6F6">
                                    <td>Hệ số vay/ NVCSH</td>
                                    <?php 
                                        foreach($company_info['finance_basic'] as $finance)
                                        {
                                    ?>
                                    <td>
                                        <table border="0" width="100%">
                                            <tr><td align="left" colspan="2"><? echo $finance['hsv'].'%';?></td></tr>
                                        </table>
                                    </td>
                                    <?php                                             
                                        }
                                    ?>
                                </tr>
                            </table>
                            <?php 
                            }
                        ?>
                        </div>
                    </div>
                    <div id="tabs-2">
                        <div class="clear"></div>
                        <div align="left" style="font-size: 12px; width: 100%;">                        
                        <?php
                            if(isset($company_info['basic']['name']))
                            {
                                $basic_info = $company_info['basic']['info'];
                                echo html_entity_decode($basic_info,ENT_QUOTES,'UTF-8');
                                echo "<br/>";
                                echo "<br/>";
                        ?>
                            <font color="#DB2298" style="font-weight: bold;">Tên công ty:</font> <?php echo $company_info['basic']['name']; ?> <br/>
                            <font color="#DB2298" style="font-weight: bold;">Địa chỉ:</font> <?php echo $company_info['basic']['address']; ?> <br/>
                            <font color="#DB2298" style="font-weight: bold;">Website:</font> <a href="<?php echo $company_info['basic']['website']; ?>" target="blank"><?php echo $company_info['basic']['website']; ?> </a><br/>
                            <font color="#DB2298" style="font-weight: bold;">Email:</font> <?php echo $company_info['basic']['email']; ?> <br/>
                        <?php
                            } 
                        ?>
                        </div>
                    </div>
                    <div id="tabs-3">
                        <div id="companyManagement" align="left" style="font-size: 12px; width: 100%;">
                        
                        <?php 
                            if(isset($company_info['position']))
                            {                                
                                foreach($company_info['position'] as $key => $value)    
                                {
                                    echo "<br/>";
                                    echo "<h1>".$key."</h1>";
                                    //echo "<hr>";
                        ?>
                        <table align="center" width="100%" cellpadding="0" cellspacing="0" border="0">
                            <tr>
                                <th align="left">Họ tên</th>
                                <th align="center">Tuổi</th>
                                <th align="left">Quá trình công tác</th>
                                <th align="left"></th>
                            </tr>
                            <?php 
                                        $i = 0;
                                       foreach($company_info['position'][$key] as $v)  
                                       {
                                           $style = ($i % 2 == 0) ? 'style="background-color: #FFFFFF;"' : 'style="background-color: #F6F6F6;"';
                            ?>
                             <tr valign="middle" <?php echo $style; ?>>
                                <td style="padding-left: 5px" width="35%"><?php echo $v['fullname'];?></td>
                                <td width="10%" align="center"><?php echo $v['age'];?></td>
                                <td width="45%"><?php echo $v['work_process'];?></td>
                                <td width="10%" align="center"><img width="36" height="45" src="<?php echo base_url(); ?>uploads/company/CEO_060925.png" alt=""></td>
                            </tr>
                            <?php ?>
                        
                        <?php 
                                        $i++; 
                                       }
                        echo "</table>";
                                }
                        echo "<br/>";
                            }
                        ?>
                        
                        </div>
                    </div>
                    <div id="tabs-4">
                        <div id="companyManagement" align="left" style="font-size: 12px; width: 100%;">
                        <?php
                        if(isset($company_info['basic_report']))
                        {
                        ?>
                            <table align="center" width="100%" cellpadding="0" cellspacing="0" border="0">
                            <tr>
                                <th align="left">Loại báo cáo</th>
                                <th align="center">Tải về</th>
                            </tr>
                       <?php 
                            $i = 0;
                            foreach($company_info['basic_report'] as $key => $value)    
                            {             
                                $style = ($i % 2 == 0) ? 'style="background-color: #FFFFFF;"' : 'style="background-color: #F6F6F6;"';                     
                        ?>
                            <tr valign="middle" <?php echo $style; ?> >
                                <td height="25" style="padding-left: 5px" width="80%"><a href="<?php echo base_url(); ?>uploads/company/report/<?php echo $value['upload'] ?>" target="blank"><?php echo $value['title'];?></a></td>
                                <td width="20%" align="center">
                                    <a href="<?php echo base_url(); ?>uploads/company/report/<?php echo $value['upload'] ?>" target="blank">
                                        <img width="16" height="16" src="<?php echo base_url(); ?>/images/<?php echo $value['filetype'] ?>" alt="">
                                    </a>
                                </td>
                            </tr>
                        <?php
                                $i++;
                            }
                        ?>    
                            </table>
                        <?php
                        }
                        ?>
                        </div>
                    </div>
                    <div id="tabs-5">
                        <div id="companyManagement" align="left" style="font-size: 12px; width: 100%;">
                        <?php
                        if(isset($company_info['finance_report']))
                        {
                        ?>
                            <table align="center" width="100%" cellpadding="0" cellspacing="0" border="0">
                            <tr>
                                <th align="left">Loại báo cáo</th>
                                <th align="center">Tải về</th>
                            </tr>
                       <?php 
                            $i = 0;
                            foreach($company_info['finance_report'] as $key => $value)    
                            {             
                                $style = ($i % 2 == 0) ? 'style="background-color: #FFFFFF;"' : 'style="background-color: #F6F6F6;"';                     
                        ?>
                            <tr valign="middle" <?php echo $style; ?> >
                                <td height="25" style="padding-left: 5px" width="80%"><a href="<?php echo base_url(); ?>uploads/company/report/<?php echo $value['upload'] ?>" target="blank"><?php echo $value['title'];?></a></td>
                                <td width="20%" align="center">
                                    <a href="<?php echo base_url(); ?>uploads/company/report/<?php echo $value['upload'] ?>" target="blank">
                                        <img width="16" height="16" src="<?php echo base_url(); ?>/images/<?php echo $value['filetype'] ?>" alt="">
                                    </a>
                                </td>
                            </tr>
                        <?php
                                $i++;
                            }
                        ?>    
                            </table>
                        <?php
                        }
                        ?>
                        </div>
                    </div>
                </div>
                <br/>
                <!-- thong tin công ty -->
            </div>
                    </td>
                    <td><div id="rightContent" style="height: auto;">
                <!-- index table -->
                <div id="indextbl">Index</div>
                <div id="indexcontent" style="background-color: #FFFFFF;" class="halfmoon">
                <?php 
                require_once "simple_html_dom.php";
                $url = "http://www.bloomberg.com/";
                $html = file_get_html($url);

                $us = $html->find('div[id=market_snap_us]',0)->outertext;
                $europe = $html->find('div[id=market_snap_europe]',0)->outertext;
                $asia = $html->find('div[id=market_snap_asia]',0)->outertext;
                ?>
                    <ul>
                        <li><a id="US" href="#">Mỹ</a></li>
                        <li><a id="Europe" href="#">Châu Âu</a></li>
                        <li><a id="Asia" href="#">Châu Á</a></li>
                    </ul>
                    <br/>
                    <div id="indexUS">
                       <?php echo str_replace('/quote/','http://www.bloomberg.com/quote/',$us); ?> 
                    </div>
                    <div id="indexEurope" style="display: none;"> 
                       <?php echo str_replace('/quote/','http://www.bloomberg.com/quote/',$europe); ?>
                    </div>
                    <div id="indexAsia" style="display: none;">
                       <?php echo str_replace('/quote/','http://www.bloomberg.com/quote/',$asia); ?>
                    </div>
                    <script>          
                       $("#US").click(function() {
                          $('#indexUS').show('slow');
                          $('#indexEurope').hide();
                          $('#indexAsia').hide();
                        });
                         
                       $("#Europe").click(function() {
                          $('#indexEurope').show('slow');
                          $('#indexUS').hide();
                          $('#indexAsia').hide();
                        });

                       $("#Asia").click(function() {
                          $('#indexAsia').show('slow');
                          $('#indexEurope').hide();
                          $('#indexUS').hide();
                        });
                    </script>
                    <br/>
                </div>
                <!-- index table -->
                
                <br/>
                <!-- nha dau tu -->
                <div id="indextbl">Nhà đầu tư</div>  
                <div id="indexcontent" style="background-color: #FFFFFF;" class="halfmoon">
                <table id="nhadautu" border="1" width="100%" style="background-color: #FFFFFF;">
                    <tr style="height: 24px;" align="center">
                        <td colspan="3" width="50%" style="border-right: 1px solid #CCCCCC;">NDT NƯỚC NGOÀI</td>
                        <td colspan="3" width="50%">NDT TRONG NƯỚC</td>
                    </tr>
                    <tr style="height: 24px;" align="center">
                        <th>&nbsp;</th>
                        <th>Mua</th>
                        <th>Bán</th>
                        <th>&nbsp;</th>
                        <th>Mua</th>
                        <th>Bán</th>
                    </tr>                    
                    <tr>
                    <?php
                            foreach( $investor_foreign as $investor )
                            {
                    ?>
                        <td class="alt3"><?php echo $investor['name'] ?></td><td class="alt2"><?php echo $investor['buy'] ?></td><td class="alt2"><?php echo $investor['sell'] ?></td>
                        <?php
                            }
                        ?>
                    </tr>
                    <tr>
                        <?php
                            foreach( $investor_data as $investor )
                            {
                        ?>
                        <td class="alt3"><?php echo $investor['name'] ?></td><td class="alt2"><?php echo $investor['buy'] ?></td><td class="alt2"><?php echo $investor['sell'] ?></td>
                        <?php
                            }
                        ?>
                    </tr>
                
                </table>
                </div>
                <!-- nha dau tu -->
                <br/>
                <!-- bao cao phan tich -->
                <div id="indextbl">BÁO CÁO PHÂN TÍCH</div>  
                <div id="indexcontent" style="background-color: #FFFFFF;" class="halfmoon">                    
                    <?php
                        foreach($analyze_reports as $report)
                        {
                    ?>
                        <p>&raquo; <a href="<?php echo base_url(); ?>uploads/company/report/<?php echo $report['upload'] ?>" target="blank" class="normalNews"><?php echo $report['title'] ?></a></p>            
                    <?php
                        }
                    ?>
                </div>
                <!-- bao cao phan tich -->
            </div></td>
                </tr>
            </table>
        </div>
        <div class="clear" style="height: 2px; background-color: #FFFFFF; width: 987;"></div>
<?php
    echo Modules::run('ndh/footer');
?>
